<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>React学习第一章</title>
  <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
class HelloWorld extends React.Component{
  constructor (props){
    super(props);
    this.state = {date:new Date()}
  }
  render(){
    return <div><h1>世界</h1><h2>{this.state.date.toLocaleTimeString()}</h2></div>
  }
}

class Clock extends React.Component{
  constructor (p){
    super(p)
    this.state = {date:new Date()}
  }
  render(){
    return <div><h1>世界</h1><h2>{this.state.date.toLocaleTimeString()}</h2></div>
  }
}
class Welcome extends React.Component {
  render() {
    return <div><h1>欢迎</h1> <Clock></Clock>!</div>;
  }
}


function tick() {
  const element = (
    <div>
      <h1>Hello, world!</h1>
      <h2>It is {new Date().toLocaleTimeString()}.</h2>
    </div>
  );
  // highlight-next-line
  ReactDOM.render(element, document.getElementById('root'));
}


setInterval(tick, 1000);

</script>
</html>
